// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_float_from_datetimev2_0_part9") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part9_9_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part9_9_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part9_9_nullable values (0, "9999-01-28 23:00:00"),(1, "9999-01-28 23:00:00"),(2, "9999-01-28 23:00:00"),(3, "9999-01-28 23:00:01"),(4, "9999-01-28 23:00:01"),(5, "9999-01-28 23:00:01"),(6, "9999-01-28 23:00:59"),(7, "9999-01-28 23:00:59"),(8, "9999-01-28 23:00:59"),(9, "9999-01-28 23:01:00"),(10, "9999-01-28 23:01:00"),(11, "9999-01-28 23:01:00"),(12, "9999-01-28 23:01:01"),(13, "9999-01-28 23:01:01"),(14, "9999-01-28 23:01:01"),(15, "9999-01-28 23:01:59"),(16, "9999-01-28 23:01:59"),(17, "9999-01-28 23:01:59"),(18, "9999-01-28 23:59:00"),(19, "9999-01-28 23:59:00"),
      (20, "9999-01-28 23:59:00"),(21, "9999-01-28 23:59:01"),(22, "9999-01-28 23:59:01"),(23, "9999-01-28 23:59:01"),(24, "9999-01-28 23:59:59"),(25, "9999-01-28 23:59:59"),(26, "9999-01-28 23:59:59"),(27, "9999-12-01 00:00:00"),(28, "9999-12-01 00:00:00"),(29, "9999-12-01 00:00:00"),(30, "9999-12-01 00:00:01"),(31, "9999-12-01 00:00:01"),(32, "9999-12-01 00:00:01"),(33, "9999-12-01 00:00:59"),(34, "9999-12-01 00:00:59"),(35, "9999-12-01 00:00:59"),(36, "9999-12-01 00:01:00"),(37, "9999-12-01 00:01:00"),(38, "9999-12-01 00:01:00"),(39, "9999-12-01 00:01:01"),
      (40, "9999-12-01 00:01:01"),(41, "9999-12-01 00:01:01"),(42, "9999-12-01 00:01:59"),(43, "9999-12-01 00:01:59"),(44, "9999-12-01 00:01:59"),(45, "9999-12-01 00:59:00"),(46, "9999-12-01 00:59:00"),(47, "9999-12-01 00:59:00"),(48, "9999-12-01 00:59:01"),(49, "9999-12-01 00:59:01"),(50, "9999-12-01 00:59:01"),(51, "9999-12-01 00:59:59"),(52, "9999-12-01 00:59:59"),(53, "9999-12-01 00:59:59"),(54, "9999-12-01 01:00:00"),(55, "9999-12-01 01:00:00"),(56, "9999-12-01 01:00:00"),(57, "9999-12-01 01:00:01"),(58, "9999-12-01 01:00:01"),(59, "9999-12-01 01:00:01"),
      (60, "9999-12-01 01:00:59"),(61, "9999-12-01 01:00:59"),(62, "9999-12-01 01:00:59"),(63, "9999-12-01 01:01:00"),(64, "9999-12-01 01:01:00"),(65, "9999-12-01 01:01:00"),(66, "9999-12-01 01:01:01"),(67, "9999-12-01 01:01:01"),(68, "9999-12-01 01:01:01"),(69, "9999-12-01 01:01:59"),(70, "9999-12-01 01:01:59"),(71, "9999-12-01 01:01:59"),(72, "9999-12-01 01:59:00"),(73, "9999-12-01 01:59:00"),(74, "9999-12-01 01:59:00"),(75, "9999-12-01 01:59:01"),(76, "9999-12-01 01:59:01"),(77, "9999-12-01 01:59:01"),(78, "9999-12-01 01:59:59"),(79, "9999-12-01 01:59:59"),
      (80, "9999-12-01 01:59:59"),(81, "9999-12-01 23:00:00"),(82, "9999-12-01 23:00:00"),(83, "9999-12-01 23:00:00"),(84, "9999-12-01 23:00:01"),(85, "9999-12-01 23:00:01"),(86, "9999-12-01 23:00:01"),(87, "9999-12-01 23:00:59"),(88, "9999-12-01 23:00:59"),(89, "9999-12-01 23:00:59"),(90, "9999-12-01 23:01:00"),(91, "9999-12-01 23:01:00"),(92, "9999-12-01 23:01:00"),(93, "9999-12-01 23:01:01"),(94, "9999-12-01 23:01:01"),(95, "9999-12-01 23:01:01"),(96, "9999-12-01 23:01:59"),(97, "9999-12-01 23:01:59"),(98, "9999-12-01 23:01:59"),(99, "9999-12-01 23:59:00"),
      (100, "9999-12-01 23:59:00"),(101, "9999-12-01 23:59:00"),(102, "9999-12-01 23:59:01"),(103, "9999-12-01 23:59:01"),(104, "9999-12-01 23:59:01"),(105, "9999-12-01 23:59:59"),(106, "9999-12-01 23:59:59"),(107, "9999-12-01 23:59:59"),(108, "9999-12-28 00:00:00"),(109, "9999-12-28 00:00:00"),(110, "9999-12-28 00:00:00"),(111, "9999-12-28 00:00:01"),(112, "9999-12-28 00:00:01"),(113, "9999-12-28 00:00:01"),(114, "9999-12-28 00:00:59"),(115, "9999-12-28 00:00:59"),(116, "9999-12-28 00:00:59"),(117, "9999-12-28 00:01:00"),(118, "9999-12-28 00:01:00"),(119, "9999-12-28 00:01:00"),
      (120, "9999-12-28 00:01:01"),(121, "9999-12-28 00:01:01"),(122, "9999-12-28 00:01:01"),(123, "9999-12-28 00:01:59"),(124, "9999-12-28 00:01:59"),(125, "9999-12-28 00:01:59"),(126, "9999-12-28 00:59:00"),(127, "9999-12-28 00:59:00"),(128, "9999-12-28 00:59:00"),(129, "9999-12-28 00:59:01"),(130, "9999-12-28 00:59:01"),(131, "9999-12-28 00:59:01"),(132, "9999-12-28 00:59:59"),(133, "9999-12-28 00:59:59"),(134, "9999-12-28 00:59:59"),(135, "9999-12-28 01:00:00"),(136, "9999-12-28 01:00:00"),(137, "9999-12-28 01:00:00"),(138, "9999-12-28 01:00:01"),(139, "9999-12-28 01:00:01"),
      (140, "9999-12-28 01:00:01"),(141, "9999-12-28 01:00:59"),(142, "9999-12-28 01:00:59"),(143, "9999-12-28 01:00:59"),(144, "9999-12-28 01:01:00"),(145, "9999-12-28 01:01:00"),(146, "9999-12-28 01:01:00"),(147, "9999-12-28 01:01:01"),(148, "9999-12-28 01:01:01"),(149, "9999-12-28 01:01:01"),(150, "9999-12-28 01:01:59"),(151, "9999-12-28 01:01:59"),(152, "9999-12-28 01:01:59"),(153, "9999-12-28 01:59:00"),(154, "9999-12-28 01:59:00"),(155, "9999-12-28 01:59:00"),(156, "9999-12-28 01:59:01"),(157, "9999-12-28 01:59:01"),(158, "9999-12-28 01:59:01"),(159, "9999-12-28 01:59:59"),
      (160, "9999-12-28 01:59:59"),(161, "9999-12-28 01:59:59"),(162, "9999-12-28 23:00:00"),(163, "9999-12-28 23:00:00"),(164, "9999-12-28 23:00:00"),(165, "9999-12-28 23:00:01"),(166, "9999-12-28 23:00:01"),(167, "9999-12-28 23:00:01"),(168, "9999-12-28 23:00:59"),(169, "9999-12-28 23:00:59"),(170, "9999-12-28 23:00:59"),(171, "9999-12-28 23:01:00"),(172, "9999-12-28 23:01:00"),(173, "9999-12-28 23:01:00"),(174, "9999-12-28 23:01:01"),(175, "9999-12-28 23:01:01"),(176, "9999-12-28 23:01:01"),(177, "9999-12-28 23:01:59"),(178, "9999-12-28 23:01:59"),(179, "9999-12-28 23:01:59"),
      (180, "9999-12-28 23:59:00"),(181, "9999-12-28 23:59:00"),(182, "9999-12-28 23:59:00"),(183, "9999-12-28 23:59:01"),(184, "9999-12-28 23:59:01"),(185, "9999-12-28 23:59:01"),(186, "9999-12-28 23:59:59"),(187, "9999-12-28 23:59:59"),(188, "9999-12-28 23:59:59")
      ,(189, null);
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part9_9_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_9_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part9_9_nullable order by 1;'

    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part9_9_not_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part9_9_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part9_9_not_nullable values (0, "9999-01-28 23:00:00"),(1, "9999-01-28 23:00:00"),(2, "9999-01-28 23:00:00"),(3, "9999-01-28 23:00:01"),(4, "9999-01-28 23:00:01"),(5, "9999-01-28 23:00:01"),(6, "9999-01-28 23:00:59"),(7, "9999-01-28 23:00:59"),(8, "9999-01-28 23:00:59"),(9, "9999-01-28 23:01:00"),(10, "9999-01-28 23:01:00"),(11, "9999-01-28 23:01:00"),(12, "9999-01-28 23:01:01"),(13, "9999-01-28 23:01:01"),(14, "9999-01-28 23:01:01"),(15, "9999-01-28 23:01:59"),(16, "9999-01-28 23:01:59"),(17, "9999-01-28 23:01:59"),(18, "9999-01-28 23:59:00"),(19, "9999-01-28 23:59:00"),
      (20, "9999-01-28 23:59:00"),(21, "9999-01-28 23:59:01"),(22, "9999-01-28 23:59:01"),(23, "9999-01-28 23:59:01"),(24, "9999-01-28 23:59:59"),(25, "9999-01-28 23:59:59"),(26, "9999-01-28 23:59:59"),(27, "9999-12-01 00:00:00"),(28, "9999-12-01 00:00:00"),(29, "9999-12-01 00:00:00"),(30, "9999-12-01 00:00:01"),(31, "9999-12-01 00:00:01"),(32, "9999-12-01 00:00:01"),(33, "9999-12-01 00:00:59"),(34, "9999-12-01 00:00:59"),(35, "9999-12-01 00:00:59"),(36, "9999-12-01 00:01:00"),(37, "9999-12-01 00:01:00"),(38, "9999-12-01 00:01:00"),(39, "9999-12-01 00:01:01"),
      (40, "9999-12-01 00:01:01"),(41, "9999-12-01 00:01:01"),(42, "9999-12-01 00:01:59"),(43, "9999-12-01 00:01:59"),(44, "9999-12-01 00:01:59"),(45, "9999-12-01 00:59:00"),(46, "9999-12-01 00:59:00"),(47, "9999-12-01 00:59:00"),(48, "9999-12-01 00:59:01"),(49, "9999-12-01 00:59:01"),(50, "9999-12-01 00:59:01"),(51, "9999-12-01 00:59:59"),(52, "9999-12-01 00:59:59"),(53, "9999-12-01 00:59:59"),(54, "9999-12-01 01:00:00"),(55, "9999-12-01 01:00:00"),(56, "9999-12-01 01:00:00"),(57, "9999-12-01 01:00:01"),(58, "9999-12-01 01:00:01"),(59, "9999-12-01 01:00:01"),
      (60, "9999-12-01 01:00:59"),(61, "9999-12-01 01:00:59"),(62, "9999-12-01 01:00:59"),(63, "9999-12-01 01:01:00"),(64, "9999-12-01 01:01:00"),(65, "9999-12-01 01:01:00"),(66, "9999-12-01 01:01:01"),(67, "9999-12-01 01:01:01"),(68, "9999-12-01 01:01:01"),(69, "9999-12-01 01:01:59"),(70, "9999-12-01 01:01:59"),(71, "9999-12-01 01:01:59"),(72, "9999-12-01 01:59:00"),(73, "9999-12-01 01:59:00"),(74, "9999-12-01 01:59:00"),(75, "9999-12-01 01:59:01"),(76, "9999-12-01 01:59:01"),(77, "9999-12-01 01:59:01"),(78, "9999-12-01 01:59:59"),(79, "9999-12-01 01:59:59"),
      (80, "9999-12-01 01:59:59"),(81, "9999-12-01 23:00:00"),(82, "9999-12-01 23:00:00"),(83, "9999-12-01 23:00:00"),(84, "9999-12-01 23:00:01"),(85, "9999-12-01 23:00:01"),(86, "9999-12-01 23:00:01"),(87, "9999-12-01 23:00:59"),(88, "9999-12-01 23:00:59"),(89, "9999-12-01 23:00:59"),(90, "9999-12-01 23:01:00"),(91, "9999-12-01 23:01:00"),(92, "9999-12-01 23:01:00"),(93, "9999-12-01 23:01:01"),(94, "9999-12-01 23:01:01"),(95, "9999-12-01 23:01:01"),(96, "9999-12-01 23:01:59"),(97, "9999-12-01 23:01:59"),(98, "9999-12-01 23:01:59"),(99, "9999-12-01 23:59:00"),
      (100, "9999-12-01 23:59:00"),(101, "9999-12-01 23:59:00"),(102, "9999-12-01 23:59:01"),(103, "9999-12-01 23:59:01"),(104, "9999-12-01 23:59:01"),(105, "9999-12-01 23:59:59"),(106, "9999-12-01 23:59:59"),(107, "9999-12-01 23:59:59"),(108, "9999-12-28 00:00:00"),(109, "9999-12-28 00:00:00"),(110, "9999-12-28 00:00:00"),(111, "9999-12-28 00:00:01"),(112, "9999-12-28 00:00:01"),(113, "9999-12-28 00:00:01"),(114, "9999-12-28 00:00:59"),(115, "9999-12-28 00:00:59"),(116, "9999-12-28 00:00:59"),(117, "9999-12-28 00:01:00"),(118, "9999-12-28 00:01:00"),(119, "9999-12-28 00:01:00"),
      (120, "9999-12-28 00:01:01"),(121, "9999-12-28 00:01:01"),(122, "9999-12-28 00:01:01"),(123, "9999-12-28 00:01:59"),(124, "9999-12-28 00:01:59"),(125, "9999-12-28 00:01:59"),(126, "9999-12-28 00:59:00"),(127, "9999-12-28 00:59:00"),(128, "9999-12-28 00:59:00"),(129, "9999-12-28 00:59:01"),(130, "9999-12-28 00:59:01"),(131, "9999-12-28 00:59:01"),(132, "9999-12-28 00:59:59"),(133, "9999-12-28 00:59:59"),(134, "9999-12-28 00:59:59"),(135, "9999-12-28 01:00:00"),(136, "9999-12-28 01:00:00"),(137, "9999-12-28 01:00:00"),(138, "9999-12-28 01:00:01"),(139, "9999-12-28 01:00:01"),
      (140, "9999-12-28 01:00:01"),(141, "9999-12-28 01:00:59"),(142, "9999-12-28 01:00:59"),(143, "9999-12-28 01:00:59"),(144, "9999-12-28 01:01:00"),(145, "9999-12-28 01:01:00"),(146, "9999-12-28 01:01:00"),(147, "9999-12-28 01:01:01"),(148, "9999-12-28 01:01:01"),(149, "9999-12-28 01:01:01"),(150, "9999-12-28 01:01:59"),(151, "9999-12-28 01:01:59"),(152, "9999-12-28 01:01:59"),(153, "9999-12-28 01:59:00"),(154, "9999-12-28 01:59:00"),(155, "9999-12-28 01:59:00"),(156, "9999-12-28 01:59:01"),(157, "9999-12-28 01:59:01"),(158, "9999-12-28 01:59:01"),(159, "9999-12-28 01:59:59"),
      (160, "9999-12-28 01:59:59"),(161, "9999-12-28 01:59:59"),(162, "9999-12-28 23:00:00"),(163, "9999-12-28 23:00:00"),(164, "9999-12-28 23:00:00"),(165, "9999-12-28 23:00:01"),(166, "9999-12-28 23:00:01"),(167, "9999-12-28 23:00:01"),(168, "9999-12-28 23:00:59"),(169, "9999-12-28 23:00:59"),(170, "9999-12-28 23:00:59"),(171, "9999-12-28 23:01:00"),(172, "9999-12-28 23:01:00"),(173, "9999-12-28 23:01:00"),(174, "9999-12-28 23:01:01"),(175, "9999-12-28 23:01:01"),(176, "9999-12-28 23:01:01"),(177, "9999-12-28 23:01:59"),(178, "9999-12-28 23:01:59"),(179, "9999-12-28 23:01:59"),
      (180, "9999-12-28 23:59:00"),(181, "9999-12-28 23:59:00"),(182, "9999-12-28 23:59:00"),(183, "9999-12-28 23:59:01"),(184, "9999-12-28 23:59:01"),(185, "9999-12-28 23:59:01"),(186, "9999-12-28 23:59:59"),(187, "9999-12-28 23:59:59"),(188, "9999-12-28 23:59:59");
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part9_9_not_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_9_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part9_9_not_nullable order by 1;'

}